<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    
    //切换语言
    public function setLocaleLang($locale){
    	if(array_key_exists($locale, config('app.locales'))){
    		Session::put('locale',$locale);
    	}
    	return redirect()
    			->back()	
    			->withInput();
    }
    
    
    public function getjichuziliao22(Request $request){
    	$typeid = $request->get('typeid');
    	if($typeid == 30){
    		//部门名称 30
    		$sql_1= "SELECT finterid,fname,ftypeid,fid FROM gz_submessage where FTypeID= 30 order by ftypeid ,fid ";
    	}elseif ($typeid ==  23){
    		//学历 23
    		$sql_1="select finterid,fname,ftypeid,fid from gz_submessage where FTypeID= 23 order by ftypeid ,fid";
    	}elseif ($typeid == 29){
    		//职务 29
    		$sql_1="select finterid,fname,ftypeid,fid from gz_submessage where FTypeID= 29 order by ftypeid ,fid";
    	}elseif ($typeid == 102){
    		//性别 102
    		$sql_1="select finterid,fname,ftypeid,fid from gz_submessage where FTypeID= 102 order by ftypeid ,fid";
    	}elseif ($typeid == 26){
    		//区域 26
    		$sql_1="select finterid,fname from gz_submessage where FTypeID= 26 order by ftypeid ,fid";
    	}elseif ($typeid == 200){
    		//离职 200
    		$sql_1="select finterid,fname from gz_submessage where FTypeID= 200 order by ftypeid ,fid";
    	}elseif ($typeid == 301){
    		//单位  301
    		$sql_1="select finterid,fname from gz_submessage where FTypeID= 301 order by ftypeid ,fid";
    	}elseif ($typeid == 302){
    		//公司名称  302
    		$sql_1="select finterid,fname from gz_submessage where FTypeID= 302 order by ftypeid ,fid";
    	}else{
    		$sql_1="SELECT finterid ,fname,ftypeid,fid FROM gz_submessage where FTypeID= 30
			UNION all
			select finterid,fname,ftypeid,fid from gz_submessage where FTypeID= 23
			UNION all
			select finterid,fname,ftypeid,fid from gz_submessage where FTypeID= 29
			UNION all
			select finterid,fname,ftypeid,fid from gz_submessage where FTypeID= 102
			UNION all
			select finterid,fname,ftypeid,fid from gz_submessage where FTypeID= 26
			UNION all
			select finterid,fname,ftypeid,fid from gz_submessage where FTypeID= 301
			UNION all
			select finterid,fname,ftypeid,fid from gz_submessage where FTypeID= 302
			UNION all
			select finterid,fname,ftypeid,fid from gz_submessage where FTypeID= 200 order by ftypeid ,fid ";
    		
    		$Data = SqlServerUtil::exec($this->SqlServer,$sql_1);
    		$temp=['23'=>'fdegree','29'=>'fduty','30'=>'fdepid','102'=>'fgender','26'=>'quyu','200'=>'fdeleted','301'=>'funit','302'=>'fcompany'];
    		$Data2 =[];
    		foreach ($Data as $k =>$v)
    		{
    			$Data2[$temp[$v['ftypeid']]][] =$v;
    			//$Data2['bb'][$temp[$v['ftypeid']]][] =$v;
    		}
    		
    		return $Data2;
    	}
    	
    	$Data = SqlServerUtil::exec($this->SqlServer,$sql_1);
    	return $Data;
    }
}
